/**
 * Copyright 2019-2020 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef INC_FRAMEWORK_COMMON_TYPES_H_
#define INC_FRAMEWORK_COMMON_TYPES_H_

#include <limits.h>
#include <linux/limits.h>
#include <stdint.h>
#include <algorithm>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "framework/common/fmk_error_codes.h"
#include "framework/common/fmk_types.h"
#include "framework/common/op_types.h"
#include "register/register_types.h"

#if !defined(__ANDROID__) && !defined(ANDROID)
#define DOMI_DYNAMIC_CAST static_cast
#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast
#else
#define DOMI_DYNAMIC_CAST static_cast
#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast
#endif

namespace ge {
// dump
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMP_MODEL;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMP_ALL_MODEL;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMP_STATUS;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMP_LAYER;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMP_FILE_PATH;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMP_MODE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_DEBUG_AICORE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_DEBUG_ATOMIC;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_DEBUG_ALL;

// Supported public properties name
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROP_OME_START_TIME;  // Start time
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROP_OME_DUMP_PATH;   // Dump path
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROP_OME_LOG_PATH;    // Log path

// Profile-related constants
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CCE_PROFILE_ON;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CCE_PROFILE_OFF;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OME_PROFILE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string CCE_PROFILE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string RTS_PROFILE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILER_JOBCTX;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILER_TARGET_PATH;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string RTS_PROFILE_PATH;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_STOP_KEY;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_STOP_VALUE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::map<std::string, std::string> PROFILE_COMPONENT_MAP;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_CONFIG;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASKS;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASK_GEN_BASE_ADDR;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASK_GEN_WEIGHT_ADDR;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_FUSION_MODEL_DEF;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int MODEL_MAX_SIZE;  // Max size of 2 GB minus 1 byte.
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint64_t FILE_HEADER_MAX_SIZE;  // Max size of 3 GB.

#if !defined(__ANDROID__) && !defined(ANDROID)
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint64_t ALLOC_MEMORY_MAX_SIZE;  // Max size of 8 GB.
#else
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint64_t ALLOC_MEMORY_MAX_SIZE;  // Max size of 512M.
#endif

template <typename K, typename V>
static std::pair<V, K> flip_pair(const std::pair<K, V> &p) {
  return std::pair<V, K>(p.second, p.first);
}

template <typename K, typename V>
static std::map<V, K> flip_map(std::map<K, V> src) {
  std::map<V, K> dst;
  std::transform(src.begin(), src.end(), std::inserter(dst, dst.begin()), flip_pair<K, V>);
  return dst;
}

REGISTER_OPTYPE_DECLARE(DATA, "Data");
REGISTER_OPTYPE_DECLARE(AIPPDATA, "AippData");
REGISTER_OPTYPE_DECLARE(CONVOLUTION, "Convolution");
REGISTER_OPTYPE_DECLARE(CORRELATION, "Correlation");
REGISTER_OPTYPE_DECLARE(CORRELATIONV2, "Correlation_V2");
REGISTER_OPTYPE_DECLARE(DECONVOLUTION, "Deconvolution");
REGISTER_OPTYPE_DECLARE(POOLING, "Pooling");
REGISTER_OPTYPE_DECLARE(ELTWISE, "Eltwise");
REGISTER_OPTYPE_DECLARE(RELU, "ReLU");
REGISTER_OPTYPE_DECLARE(RELU6, "ReLU6");
REGISTER_OPTYPE_DECLARE(SIGMOID, "Sigmoid");
REGISTER_OPTYPE_DECLARE(ABSVAL, "AbsVal");
REGISTER_OPTYPE_DECLARE(TANH, "TanH");
REGISTER_OPTYPE_DECLARE(PRELU, "PReLU");
REGISTER_OPTYPE_DECLARE(BATCHNORM, "BatchNorm");
REGISTER_OPTYPE_DECLARE(FUSIONBATCHNORM, "FusionBatchNorm");
REGISTER_OPTYPE_DECLARE(SCALE, "Scale");
REGISTER_OPTYPE_DECLARE(FULL_CONNECTION, "FullConnection");
REGISTER_OPTYPE_DECLARE(SOFTMAX, "Softmax");
REGISTER_OPTYPE_DECLARE(PLUS, "Plus");
REGISTER_OPTYPE_DECLARE(ACTIVATION, "Activation");
REGISTER_OPTYPE_DECLARE(FLATTEN, "Flatten");
REGISTER_OPTYPE_DECLARE(ADD, "Add");
REGISTER_OPTYPE_DECLARE(SUB, "Sub");
REGISTER_OPTYPE_DECLARE(MUL, "Mul");
REGISTER_OPTYPE_DECLARE(MATMUL, "MatMul");
REGISTER_OPTYPE_DECLARE(RSQRT, "Rsqrt");
REGISTER_OPTYPE_DECLARE(BIASADD, "BiasAdd");
REGISTER_OPTYPE_DECLARE(RESHAPE, "Reshape");
REGISTER_OPTYPE_DECLARE(REFORMAT, "ReFormat");
REGISTER_OPTYPE_DECLARE(DEPCONVOLUTION, "ConvolutionDepthwise");
REGISTER_OPTYPE_DECLARE(DROPOUT, "Dropout");
REGISTER_OPTYPE_DECLARE(DROPOUTDOMASK, "DropOutDoMask");
REGISTER_OPTYPE_DECLARE(DROPOUTGENMASK, "DropOutGenMask");
REGISTER_OPTYPE_DECLARE(CONCAT, "Concat");
REGISTER_OPTYPE_DECLARE(ROIPOOLING, "ROIPooling");
REGISTER_OPTYPE_DECLARE(PROPOSAL, "Proposal");
REGISTER_OPTYPE_DECLARE(FSRDETECTIONOUTPUT, "FSRDetectionOutput");
REGISTER_OPTYPE_DECLARE(DETECTIONPOSTPROCESS, "Detectpostprocess");
REGISTER_OPTYPE_DECLARE(LRN, "LRN");
REGISTER_OPTYPE_DECLARE(TRANSDATA, "TransData");
REGISTER_OPTYPE_DECLARE(PERMUTE, "Permute");
REGISTER_OPTYPE_DECLARE(SSDNORMALIZE, "SSDNormalize");
REGISTER_OPTYPE_DECLARE(SSDPRIORBOX, "SSDPriorBox");
REGISTER_OPTYPE_DECLARE(NETOUTPUT, "NetOutput");
REGISTER_OPTYPE_DECLARE(SSDDETECTIONOUTPUT, "SSDDetectionOutput");
REGISTER_OPTYPE_DECLARE(REFINEDETDETECTIONOUTPUT, "RefinedetDetectionOutput");
REGISTER_OPTYPE_DECLARE(CHANNELAXPY, "ChannelAxpy");
REGISTER_OPTYPE_DECLARE(PSROIPOOLING, "PSROIPooling");
REGISTER_OPTYPE_DECLARE(POWER, "Power");
REGISTER_OPTYPE_DECLARE(POW, "Pow");
REGISTER_OPTYPE_DECLARE(ROIALIGN, "ROIAlign");
REGISTER_OPTYPE_DECLARE(PYTHON, "Python");
REGISTER_OPTYPE_DECLARE(FREESPACEEXTRACT, "FreespaceExtract");
REGISTER_OPTYPE_DECLARE(SPATIALTF, "SpatialTransform");
REGISTER_OPTYPE_DECLARE(SHAPE, "Shape");
REGISTER_OPTYPE_DECLARE(SHAPEN, "ShapeN");
REGISTER_OPTYPE_DECLARE(ARGMAX, "ArgMax");
REGISTER_OPTYPE_DECLARE(GATHERND, "GatherNd");
REGISTER_OPTYPE_DECLARE(GATHER, "Gather");
REGISTER_OPTYPE_DECLARE(REALDIV, "RealDiv");
REGISTER_OPTYPE_DECLARE(PACK, "Pack");
REGISTER_OPTYPE_DECLARE(SLICE, "Slice");
REGISTER_OPTYPE_DECLARE(SLICED, "SliceD");
REGISTER_OPTYPE_DECLARE(FLOORDIV, "FloorDiv");
REGISTER_OPTYPE_DECLARE(SQUEEZE, "Squeeze");
REGISTER_OPTYPE_DECLARE(UNSQUEEZE, "Unsqueeze");
REGISTER_OPTYPE_DECLARE(STRIDEDSLICE, "StridedSlice");
REGISTER_OPTYPE_DECLARE(RANGE, "Range");
REGISTER_OPTYPE_DECLARE(RPNPROPOSALS, "GenerateRpnProposals");
REGISTER_OPTYPE_DECLARE(DECODEBBOX, "DecodeBBox");
REGISTER_OPTYPE_DECLARE(PAD, "Pad");
REGISTER_OPTYPE_DECLARE(PADV2, "PadV2");
REGISTER_OPTYPE_DECLARE(MIRRORPAD, "MirrorPad");
REGISTER_OPTYPE_DECLARE(TILE, "Tile");
REGISTER_OPTYPE_DECLARE(SIZE, "Size");
REGISTER_OPTYPE_DECLARE(CLIPBOXES, "Clipboxes");
REGISTER_OPTYPE_DECLARE(FASTRCNNPREDICTIONS, "FastrcnnPredictions");
REGISTER_OPTYPE_DECLARE(SPLIT, "Split");
REGISTER_OPTYPE_DECLARE(SPLITV, "SplitV");
REGISTER_OPTYPE_DECLARE(EXPANDDIMS, "ExpandDims");
REGISTER_OPTYPE_DECLARE(EMPTY, "Empty");
REGISTER_OPTYPE_DECLARE(MEAN, "Mean");
REGISTER_OPTYPE_DECLARE(GREATER, "Greater");
REGISTER_OPTYPE_DECLARE(SWITCH, "Switch");
REGISTER_OPTYPE_DECLARE(SWITCHN, "SwitchN");
REGISTER_OPTYPE_DECLARE(REFSWITCH, "RefSwitch");
REGISTER_OPTYPE_DECLARE(MERGE, "Merge");
REGISTER_OPTYPE_DECLARE(REFMERGE, "RefMerge");
REGISTER_OPTYPE_DECLARE(ENTER, "Enter");
REGISTER_OPTYPE_DECLARE(REFENTER, "RefEnter");
REGISTER_OPTYPE_DECLARE(LOOPCOND, "LoopCond");
REGISTER_OPTYPE_DECLARE(NEXTITERATION, "NextIteration");
REGISTER_OPTYPE_DECLARE(REFNEXTITERATION, "RefNextIteration");
REGISTER_OPTYPE_DECLARE(EXIT, "Exit");
REGISTER_OPTYPE_DECLARE(REFEXIT, "RefExit");
REGISTER_OPTYPE_DECLARE(CONTROLTRIGGER, "ControlTrigger");
REGISTER_OPTYPE_DECLARE(SYMBOLICGRADIENT, "SymbolicGradient");
REGISTER_OPTYPE_DECLARE(REMOTECALL, "RemoteCall");
REGISTER_OPTYPE_DECLARE(_IF, "_If");
REGISTER_OPTYPE_DECLARE(STATELESSIF, "StatelessIf");
REGISTER_OPTYPE_DECLARE(IF, "If");
REGISTER_OPTYPE_DECLARE(CASE, "Case");
REGISTER_OPTYPE_DECLARE(_WHILE, "_While");
REGISTER_OPTYPE_DECLARE(WHILE, "While");
REGISTER_OPTYPE_DECLARE(STATELESSWHILE, "StatelessWhile");
REGISTER_OPTYPE_DECLARE(FOR, "For");
REGISTER_OPTYPE_DECLARE(PARTITIONEDCALL, "PartitionedCall");
REGISTER_OPTYPE_DECLARE(STATEFULPARTITIONEDCALL, "StatefulPartitionedCall");
REGISTER_OPTYPE_DECLARE(FAKEPARAM, "FakeParam");
REGISTER_OPTYPE_DECLARE(TRANSPOSE, "Transpose");
REGISTER_OPTYPE_DECLARE(TRANSPOSED, "TransposeD");
REGISTER_OPTYPE_DECLARE(CAST, "Cast");
REGISTER_OPTYPE_DECLARE(REGION, "Region");
REGISTER_OPTYPE_DECLARE(YOLO, "Yolo");
REGISTER_OPTYPE_DECLARE(YOLODETECTIONOUTPUT, "YoloDetectionOutput");
REGISTER_OPTYPE_DECLARE(FILL, "Fill");
REGISTER_OPTYPE_DECLARE(RANK, "Rank");
REGISTER_OPTYPE_DECLARE(REVERSE, "Reverse");
REGISTER_OPTYPE_DECLARE(UNPACK, "Unpack");
REGISTER_OPTYPE_DECLARE(YOLO2REORG, "Yolo2Reorg");
REGISTER_OPTYPE_DECLARE(REDUCESUM, "ReduceSum");
REGISTER_OPTYPE_DECLARE(SUM, "Sum");
REGISTER_OPTYPE_DECLARE(CONSTANT, "Const");
REGISTER_OPTYPE_DECLARE(RESIZEBILINEAR, "ResizeBilinear");
REGISTER_OPTYPE_DECLARE(RESIZEBILINEARGRAD, "ResizeBilinearGrad");
REGISTER_OPTYPE_DECLARE(MAXIMUM, "Maximum");
REGISTER_OPTYPE_DECLARE(FRAMEWORKOP, "FrameworkOp");
REGISTER_OPTYPE_DECLARE(ARG, "_Arg");
REGISTER_OPTYPE_DECLARE(FUSEDBATCHNORMGRAD, "FusedBatchNormGrad");
REGISTER_OPTYPE_DECLARE(LSTM, "LSTM");
REGISTER_OPTYPE_DECLARE(HIGHWAY, "HighWay");
REGISTER_OPTYPE_DECLARE(RNN, "RNN");
REGISTER_OPTYPE_DECLARE(ATTENTIONDECODER, "AttentionDecoder");
REGISTER_OPTYPE_DECLARE(LOGICAL_NOT, "LogicalNot");
REGISTER_OPTYPE_DECLARE(LOGICAL_AND, "LogicalAnd");
REGISTER_OPTYPE_DECLARE(LOGICAL_OR, "LogicalOr");
REGISTER_OPTYPE_DECLARE(EQUAL, "Equal");
REGISTER_OPTYPE_DECLARE(NOTEQUAL, "NotEqual");
REGISTER_OPTYPE_DECLARE(INTERP, "Interp");
REGISTER_OPTYPE_DECLARE(SHUFFLECHANNEL, "ShuffleChannel");
REGISTER_OPTYPE_DECLARE(AIPP, "Aipp");
REGISTER_OPTYPE_DECLARE(MULTISHAPE, "MultiShape");
REGISTER_OPTYPE_DECLARE(RECIPROCAL, "Reciprocal");
REGISTER_OPTYPE_DECLARE(SELU, "Selu");
REGISTER_OPTYPE_DECLARE(ELU, "Elu");
REGISTER_OPTYPE_DECLARE(ACOSH, "Acosh");
REGISTER_OPTYPE_DECLARE(ASINH, "Asinh");
REGISTER_OPTYPE_DECLARE(MINIMUM, "Minimum");
REGISTER_OPTYPE_DECLARE(CLIP, "Clip");
REGISTER_OPTYPE_DECLARE(L2NORMALIZE, "L2Normalize");
REGISTER_OPTYPE_DECLARE(CROPANDRESIZE, "CropAndResize");
REGISTER_OPTYPE_DECLARE(UNUSEDCONST, "UnusedConst");
REGISTER_OPTYPE_DECLARE(SPARSETODENSE, "SparseToDense");
REGISTER_OPTYPE_DECLARE(NONMAXSUPPRESSION, "NonMaxSuppression");
REGISTER_OPTYPE_DECLARE(TOPKV2, "TopKV2");
REGISTER_OPTYPE_DECLARE(INVERTPERMUTATION, "InvertPermutation");
REGISTER_OPTYPE_DECLARE(MULTINOMIAL, "Multinomial");
REGISTER_OPTYPE_DECLARE(REVERSESEQUENCE, "ReverseSequence");
REGISTER_OPTYPE_DECLARE(REDUCEPROD, "ReduceProd");
REGISTER_OPTYPE_DECLARE(REDUCEMAX, "ReduceMax");
REGISTER_OPTYPE_DECLARE(REDUCEMIN, "ReduceMin");
REGISTER_OPTYPE_DECLARE(EXTRACTIMAGEPATCHES, "ExtractImagePatches");
REGISTER_OPTYPE_DECLARE(SQRT, "Sqrt");
REGISTER_OPTYPE_DECLARE(REDUCEALL, "ReduceAll");
REGISTER_OPTYPE_DECLARE(RESIZENEARESTNEIGHBOR, "ResizeNearestNeighbor");
REGISTER_OPTYPE_DECLARE(SPACETOBATCHND, "SpaceToBatchND");
REGISTER_OPTYPE_DECLARE(BATCHTOSPACEND, "BatchToSpaceND");
REGISTER_OPTYPE_DECLARE(ASSERT, "Assert");
REGISTER_OPTYPE_DECLARE(GREATEREQUAL, "GreaterEqual");
REGISTER_OPTYPE_DECLARE(FLOOR, "Floor");
REGISTER_OPTYPE_DECLARE(RANDOMUNIFORM, "RandomUniform");
REGISTER_OPTYPE_DECLARE(BATCHMATMUL, "BatchMatMul");
REGISTER_OPTYPE_DECLARE(LESSEQUAL, "LessEqual");
REGISTER_OPTYPE_DECLARE(ONEHOT, "OneHot");
REGISTER_OPTYPE_DECLARE(LAYERNORM, "LayerNorm");
REGISTER_OPTYPE_DECLARE(SPACETODEPTH, "SpaceToDepth");
REGISTER_OPTYPE_DECLARE(DEPTHTOSPACE, "DepthToSpace");
REGISTER_OPTYPE_DECLARE(RINT, "Rint");
REGISTER_OPTYPE_DECLARE(ATAN, "Atan");
REGISTER_OPTYPE_DECLARE(ATAN2, "Atan2");
REGISTER_OPTYPE_DECLARE(ATANH, "Atanh");
REGISTER_OPTYPE_DECLARE(ACOS, "Acos");
REGISTER_OPTYPE_DECLARE(ASIN, "Asin");
REGISTER_OPTYPE_DECLARE(NEG, "Neg");
REGISTER_OPTYPE_DECLARE(LOG, "Log");
REGISTER_OPTYPE_DECLARE(TAN, "Tan");
REGISTER_OPTYPE_DECLARE(ROUND, "Round");
REGISTER_OPTYPE_DECLARE(UPSAMPLE, "Upsample");
REGISTER_OPTYPE_DECLARE(FLOORMOD, "FloorMod");
REGISTER_OPTYPE_DECLARE(LESS, "Less");
REGISTER_OPTYPE_DECLARE(ZEROSLIKE, "ZerosLike");
REGISTER_OPTYPE_DECLARE(EXP, "Exp");
REGISTER_OPTYPE_DECLARE(WHERE, "Where");
REGISTER_OPTYPE_DECLARE(FAKEQUANTWITHMINMAXVARS, "FakeQuantWithMinMaxVars");
REGISTER_OPTYPE_DECLARE(SOFTPLUS, "Softplus");
REGISTER_OPTYPE_DECLARE(SOFTSIGN, "Softsign");
REGISTER_OPTYPE_DECLARE(COSH, "Cosh");
REGISTER_OPTYPE_DECLARE(SINH, "Sinh");
REGISTER_OPTYPE_DECLARE(RETINAMULTIANCHORS, "RetinaMultiAnchor");
REGISTER_OPTYPE_DECLARE(SQUAREDDIFFERENCE, "SquaredDifference");
REGISTER_OPTYPE_DECLARE(REQUIREDSPACETOBATCHPADDINGS, "RequiredSpaceToBatchPaddings");  // for retinanet scope fusion
REGISTER_OPTYPE_DECLARE(SSDPOSTPROCESSOR, "SSDPostProcessor");
REGISTER_OPTYPE_DECLARE(SSDANCHORGENERATOR, "SSDAnchorGenerator");
REGISTER_OPTYPE_DECLARE(RETINANETBOXES, "RetinanetBoxes");
REGISTER_OPTYPE_DECLARE(RETINANETCLIPPEDBOXES, "RetinanetClippedBoxes");
REGISTER_OPTYPE_DECLARE(RETINANETFILTEREDDETECTIONS, "RetinanetFilteredDetections");
REGISTER_OPTYPE_DECLARE(RETINANETPOSTPROCESSOR, "RetinanetPostProcessor");
REGISTER_OPTYPE_DECLARE(RETINANETANCHORS, "RetinanetAnchors");
REGISTER_OPTYPE_DECLARE(FASTERRCNNMAP, "FasterRCNNMap");
REGISTER_OPTYPE_DECLARE(FASTERRCNNMAP1, "FasterRCNNMap1");
REGISTER_OPTYPE_DECLARE(FASTERRCNNSECONDSTAGEPOSTPROCESSOR, "FasterRCNNSecondStagePostprocessor");
REGISTER_OPTYPE_DECLARE(FASTERRCNNROIINTERPOOLING, "FasterRCNNROIInterPooling");
REGISTER_OPTYPE_DECLARE(FASTERRCNNFIRSTSTAGEPOSTPROCESSOR, "FasterRCNNFirstStagePostprocessor");
REGISTER_OPTYPE_DECLARE(FASTERRCNNGRIDANCHORGENERATOR, "FasterRCNNGridAnchorGenerator");
REGISTER_OPTYPE_DECLARE(ROIINTERPOOLING, "ROIInterPooling");
REGISTER_OPTYPE_DECLARE(FASTERRCNNCLIPTOWINDOW, "FasterRCNNClipToWindow");
REGISTER_OPTYPE_DECLARE(EMBEDLOOKUP, "EmbedLookup");
REGISTER_OPTYPE_DECLARE(HASHLOOKUP, "HashLookup");
REGISTER_OPTYPE_DECLARE(LSH_PROJ, "LshProject");
REGISTER_OPTYPE_DECLARE(SVDF, "SVDF");
REGISTER_OPTYPE_DECLARE(IDENTITY, "Identity");
REGISTER_OPTYPE_DECLARE(PLACEHOLDERWITHDEFAULT, "PlaceholderWithDefault");
REGISTER_OPTYPE_DECLARE(IDENTITYN, "IdentityN");
REGISTER_OPTYPE_DECLARE(GETSPAN, "GetSpan");
REGISTER_OPTYPE_DECLARE(STOPGRADIENT, "StopGradient");
REGISTER_OPTYPE_DECLARE(PREVENTGRADIENT, "PreventGradient");
REGISTER_OPTYPE_DECLARE(GUARANTEECONST, "GuaranteeConst");
REGISTER_OPTYPE_DECLARE(BROADCASTGRADIENTARGS, "BroadcastGradientArgs");
REGISTER_OPTYPE_DECLARE(BROADCASTARGS, "BroadcastArgs");
REGISTER_OPTYPE_DECLARE(CONCATV2, "ConcatV2");
REGISTER_OPTYPE_DECLARE(CONCATOFFSET, "ConcatOffset");
REGISTER_OPTYPE_DECLARE(LESSEQUAL, "LessEqual");
REGISTER_OPTYPE_DECLARE(SELECT, "Select");
REGISTER_OPTYPE_DECLARE(CONFUSIONMATRIX, "ConfusionMatrix");
REGISTER_OPTYPE_DECLARE(PLACEHOLDER, "PlaceHolder");
REGISTER_OPTYPE_DECLARE(END, "End");
REGISTER_OPTYPE_DECLARE(BASICLSTMCELL, "BasicLSTMCell");
REGISTER_OPTYPE_DECLARE(GETNEXT, "GetNext");
REGISTER_OPTYPE_DECLARE(INITDATA, "InitData");
REGISTER_OPTYPE_DECLARE(TRANSSHAPE, "TransShape")
REGISTER_OPTYPE_DECLARE(REFIDENTITY, "RefIdentity");
REGISTER_OPTYPE_DECLARE(BITCAST, "Bitcast");

// ANN dedicated operator
REGISTER_OPTYPE_DECLARE(ANN_MEAN, "AnnMean");
REGISTER_OPTYPE_DECLARE(ANN_CONVOLUTION, "AnnConvolution");
REGISTER_OPTYPE_DECLARE(ANN_DEPCONVOLUTION, "AnnDepthConv");
REGISTER_OPTYPE_DECLARE(ANN_FULLCONNECTION, "AnnFullConnection");
REGISTER_OPTYPE_DECLARE(ANN_NETOUTPUT, "AnnNetOutput");
REGISTER_OPTYPE_DECLARE(ANN_DATA, "AnnData");
REGISTER_OPTYPE_DECLARE(ANN_RESHAPE, "AnnReshape");
REGISTER_OPTYPE_DECLARE(ANN_ADD, "AnnAdd");
REGISTER_OPTYPE_DECLARE(ANN_MUL, "AnnMul");
REGISTER_OPTYPE_DECLARE(ANN_SUB, "AnnSub");
REGISTER_OPTYPE_DECLARE(ANN_DIV, "AnnDiv");
REGISTER_OPTYPE_DECLARE(ANN_DEQUANTIZE, "AnnDequant");
REGISTER_OPTYPE_DECLARE(ANN_QUANTIZE, "AnnQuant");
REGISTER_OPTYPE_DECLARE(ANN_PAD, "AnnPad");
REGISTER_OPTYPE_DECLARE(ANN_RESIZE_BILINEAR, "AnnResizeBilinear");

// Training operator
REGISTER_OPTYPE_DECLARE(GATHERV2, "GatherV2");
REGISTER_OPTYPE_DECLARE(CONVGRADFILTER, "Conv2DBackpropFilter");
REGISTER_OPTYPE_DECLARE(CONV2D, "Conv2D");
REGISTER_OPTYPE_DECLARE(CONV2DBACKPROPINPUT, "Conv2DBackpropInput");
REGISTER_OPTYPE_DECLARE(FUSEDBATCHNORM, "FusedBatchNorm");
REGISTER_OPTYPE_DECLARE(BIASADDGRAD, "BiasAddGrad");
REGISTER_OPTYPE_DECLARE(ACTIVATIONGRAD, "ReluGrad");
REGISTER_OPTYPE_DECLARE(MAXPOOLWITHARGMAX, "MaxPoolWithArgmax");
REGISTER_OPTYPE_DECLARE(MAXPOOLGRADWITHARGMAX, "MaxPoolGradWithArgmax");
REGISTER_OPTYPE_DECLARE(SPARSESOFTMAXCROSSENTROPYWITHLOGITS, "SparseSoftmaxCrossEntropyWithLogits");
REGISTER_OPTYPE_DECLARE(SNAPSHOT, "Snapshot");
REGISTER_OPTYPE_DECLARE(LAYERNORM, "LayerNorm");
REGISTER_OPTYPE_DECLARE(HUBERLOSSGRAD, "HuberLossGrad");
REGISTER_OPTYPE_DECLARE(HUBERLOSS, "HuberLoss");
REGISTER_OPTYPE_DECLARE(NEGATIVE, "Negative");
REGISTER_OPTYPE_DECLARE(SSDCAST, "SSDCast");
REGISTER_OPTYPE_DECLARE(SSDSQUEEZEFUSION, "SsdSqueezeFusion");
REGISTER_OPTYPE_DECLARE(SPARSESOFTMAXCROSSENTROPY, "SsdSparseSoftmaxCrossEntropy");
REGISTER_OPTYPE_DECLARE(SPARSESOFTMAXCROSSENTROPYGRAD, "SsdSparseSoftmaxCrossEntropyGrad");
REGISTER_OPTYPE_DECLARE(CONCATFIVE2FOUR, "ConcatFive2Four");
REGISTER_OPTYPE_DECLARE(CONCATFOUR2FIVE, "ConcatFour2Five");
REGISTER_OPTYPE_DECLARE(SSDREALDIVTILEMUL, "SSDRealdivTileMul");
REGISTER_OPTYPE_DECLARE(SSDSUMMULREALDIVMEAN, "SSDSumMulRealdivMean");

REGISTER_OPTYPE_DECLARE(MEANGRAD, "MeanGrad");
REGISTER_OPTYPE_DECLARE(TRANSLATE, "Translate");
REGISTER_OPTYPE_DECLARE(ADDN, "AddN");
REGISTER_OPTYPE_DECLARE(L2LOSS, "L2Loss");
REGISTER_OPTYPE_DECLARE(MULTIPLY, "Multiply");
REGISTER_OPTYPE_DECLARE(RELU6GRAD, "Relu6Grad");
REGISTER_OPTYPE_DECLARE(AVGPOOLGRAD, "AvgPoolGrad");
REGISTER_OPTYPE_DECLARE(DEPTHWISECONV2DBACKPROPFILTER, "DepthwiseConv2dNativeBackpropFilter");
REGISTER_OPTYPE_DECLARE(DEPTHWISECONV2DBACKPORPINPUT, "DepthwiseConv2dNativeBackpropInput");
REGISTER_OPTYPE_DECLARE(DEPTHWISECONV2DFORWARDNATIVE, "DepthwiseConv2dNative");
REGISTER_OPTYPE_DECLARE(DROPOUTGRAD, "DropOutGrad");
REGISTER_OPTYPE_DECLARE(APPLYRMSPROPMIXEDPRECISION, "apply_rms_prop_mixed_precision");
REGISTER_OPTYPE_DECLARE(APPLYRMSPROP, "ApplyRMSProp");
REGISTER_OPTYPE_DECLARE(LARS, "Lars");
REGISTER_OPTYPE_DECLARE(DYNAMICSTITCH, "DynamicStitch");

// Variable sink related
REGISTER_OPTYPE_DECLARE(VARIABLEV2, "VariableV2");
REGISTER_OPTYPE_DECLARE(VARHANDLEOP, "VarHandleOp");
REGISTER_OPTYPE_DECLARE(TEMPORARYVARIABLE, "TemporaryVariable");
REGISTER_OPTYPE_DECLARE(DESTROYTEMPORARYVARIABLE, "DestroyTemporaryVariable");
REGISTER_OPTYPE_DECLARE(VARIABLE, "Variable");

REGISTER_OPTYPE_DECLARE(READVARIABLEOP, "ReadVariableOp");

REGISTER_OPTYPE_DECLARE(VARISINITIALIZEDOP, "VarIsInitializedOp");
REGISTER_OPTYPE_DECLARE(ISVARIABLEINITIALIZED, "IsVariableInitialized");

REGISTER_OPTYPE_DECLARE(ASSIGN, "Assign");
REGISTER_OPTYPE_DECLARE(ASSIGNVARIABLEOP, "AssignVariableOp");

REGISTER_OPTYPE_DECLARE(ASSIGNADD, "AssignAdd");
REGISTER_OPTYPE_DECLARE(ASSIGNADDVARIABLEOP, "AssignAddVariableOp");

REGISTER_OPTYPE_DECLARE(ASSIGNSUB, "AssignSub");
REGISTER_OPTYPE_DECLARE(ASSIGNSUBVARIABLEOP, "AssignSubVariableOp");

REGISTER_OPTYPE_DECLARE(APPLYMOMENTUM, "ApplyMomentum");
REGISTER_OPTYPE_DECLARE(RESOURCEAPPLYMOMENTUM, "ResourceApplyMomentum");
REGISTER_OPTYPE_DECLARE(SGD, "SGD");
REGISTER_OPTYPE_DECLARE(NOOP, "NoOp");
REGISTER_OPTYPE_DECLARE(LAYERNORMGRAD, "LayerNormGrad");

REGISTER_OPTYPE_DECLARE(SQUARE, "Square");
REGISTER_OPTYPE_DECLARE(HCOMBROADCAST, "HcomBroadcast");
REGISTER_OPTYPE_DECLARE(HCOMALLGATHER, "HcomAllGather");
REGISTER_OPTYPE_DECLARE(HCOMALLREDUCE, "HcomAllReduce");
REGISTER_OPTYPE_DECLARE(HCOMREDUCESCATTER, "HcomReduceScatter");
REGISTER_OPTYPE_DECLARE(HCOMSEND, "HcomSend");
REGISTER_OPTYPE_DECLARE(HCOMRECEIVE, "HcomReceive");
REGISTER_OPTYPE_DECLARE(HCOMREMOTEREAD, "HcomRemoteRead");
REGISTER_OPTYPE_DECLARE(HCOMREMOTEWRITE, "HcomRemoteWrite");

REGISTER_OPTYPE_DECLARE(VARASSIGN, "VarAssign");
REGISTER_OPTYPE_DECLARE(VARISINITIALIZEDOP, "VarIsInitializedOp");
REGISTER_OPTYPE_DECLARE(LogTimeStamp, "LogTimeStamp");
REGISTER_OPTYPE_DECLARE(PARALLELCONCATSTART, "_ParallelConcatStart");
REGISTER_OPTYPE_DECLARE(CONSTANTOP, "Constant");
REGISTER_OPTYPE_DECLARE(STREAMSWITCH, "StreamSwitch");
REGISTER_OPTYPE_DECLARE(STREAMSWITCHN, "StreamSwitchN");
REGISTER_OPTYPE_DECLARE(STREAMACTIVE, "StreamActive");
REGISTER_OPTYPE_DECLARE(MEMCPYASYNC, "MemcpyAsync");
REGISTER_OPTYPE_DECLARE(MEMCPYADDRASYNC, "MemcpyAddrAsync");
REGISTER_OPTYPE_DECLARE(STREAMMERGE, "StreamMerge");
REGISTER_OPTYPE_DECLARE(ENDGRAPH, "EndGraph");
REGISTER_OPTYPE_DECLARE(SEND, "Send");
REGISTER_OPTYPE_DECLARE(RECV, "Recv");
REGISTER_OPTYPE_DECLARE(ENDOFSEQUENCE, "EndOfSequence");

REGISTER_OPTYPE_DECLARE(LABELSET, "LabelSet");
REGISTER_OPTYPE_DECLARE(LABELGOTO, "LabelGoto");
REGISTER_OPTYPE_DECLARE(LABELGOTOEX, "LabelGotoEx");
REGISTER_OPTYPE_DECLARE(LABELSWITCH, "LabelSwitch");
REGISTER_OPTYPE_DECLARE(LABELSWITCHBYINDEX, "LabelSwitchByIndex");

REGISTER_OPTYPE_DECLARE(ATOMICADDRCLEAN, "AtomicAddrClean");

REGISTER_OPTYPE_DECLARE(ABS_GRAD, "AbsGrad");
REGISTER_OPTYPE_DECLARE(ACCUMULATE_N_V2, "AccumulateNV2");
REGISTER_OPTYPE_DECLARE(ACOS_GRAD, "AcosGrad");
REGISTER_OPTYPE_DECLARE(ACOSH_GRAD, "AcoshGrad");
REGISTER_OPTYPE_DECLARE(ANY, "Any");
REGISTER_OPTYPE_DECLARE(APPROXIMATE_EQUAL, "ApproximateEqual");
REGISTER_OPTYPE_DECLARE(ASIN_GRAD, "AsinGrad");
REGISTER_OPTYPE_DECLARE(ASINH_GRAD, "AsinhGrad");
REGISTER_OPTYPE_DECLARE(ATAN_GRAD, "AtanGrad");
REGISTER_OPTYPE_DECLARE(BROADCAST_TO, "BroadcastTo");
REGISTER_OPTYPE_DECLARE(ELU_GRAD, "EluGrad");
REGISTER_OPTYPE_DECLARE(ADD_V2, "AddV2");
REGISTER_OPTYPE_DECLARE(DATAFORMATDIMMAP, "DataFormatDimMap");
REGISTER_OPTYPE_DECLARE(DATAFORMATVECPERMUTE, "DataFormatVecPermute");
REGISTER_OPTYPE_DECLARE(BESSELI0e, "BesselI0e");
REGISTER_OPTYPE_DECLARE(BESSELI1e, "BesselI1e");
REGISTER_OPTYPE_DECLARE(DEQUANTIZE, "Dequantize");
REGISTER_OPTYPE_DECLARE(APPLYADADELTA, "ApplyAdadelta");
REGISTER_OPTYPE_DECLARE(APPLYADAGRAD, "ApplyAdagrad");
REGISTER_OPTYPE_DECLARE(APPLYADAGRADDA, "ApplyAdagradDA");
REGISTER_OPTYPE_DECLARE(APPLYADAM, "ApplyAdam");
REGISTER_OPTYPE_DECLARE(APPLYADAMAX, "ApplyAdaMax");
REGISTER_OPTYPE_DECLARE(APPLYADDSIGN, "ApplyAddSign");
REGISTER_OPTYPE_DECLARE(APPLYCENTEREDRMSPROP, "ApplyCenteredRMSProp");
REGISTER_OPTYPE_DECLARE(APPLYFTRL, "ApplyFtrl");
REGISTER_OPTYPE_DECLARE(APPLYFTRLV2, "ApplyFtrlv2");
REGISTER_OPTYPE_DECLARE(APPLYGRADIENTDESCENT, "ApplyGradientDescent");
REGISTER_OPTYPE_DECLARE(APPLYPOWERSIGN, "ApplyPowerSign");
REGISTER_OPTYPE_DECLARE(APPLYPROXIMALADAGRAD, "ApplyProximalAdagrad");
REGISTER_OPTYPE_DECLARE(APPLYPROXIMALGRADIENTDESCENT, "ApplyProximalGradientDescent");

REGISTER_OPTYPE_DECLARE(FOCAL_LOSS, "FocalLoss");
REGISTER_OPTYPE_DECLARE(FOCAL_LOSS_GRAD, "FocalLossGrad");
REGISTER_OPTYPE_DECLARE(SMOOTHL1_LOSS, "SmoothL1Loss");
REGISTER_OPTYPE_DECLARE(SMOOTHL1_LOSS_grad, "SmoothL1LossGrad");
REGISTER_OPTYPE_DECLARE(REDUCEMEAN, "ReduceMean");
REGISTER_OPTYPE_DECLARE(CONCAT_V2, "ConcatV2");
REGISTER_OPTYPE_DECLARE(ONEHOT_V2, "OneHotV2");
REGISTER_OPTYPE_DECLARE(SLICE_V2, "SliceV2");
REGISTER_OPTYPE_DECLARE(TILE_V2, "TileV2");
REGISTER_OPTYPE_DECLARE(SUM_V2, "SumV2");
// Common operator type when operators have the same name
REGISTER_OPTYPE_DECLARE(DETECTIONOUTPUT, "DetectionOutput");

// custom operator
REGISTER_OPTYPE_DECLARE(CUSTOMOP, "CustomOp");
REGISTER_OPTYPE_DECLARE(CUSTOMOP_NCHW, "CustomOpNchw");
REGISTER_OPTYPE_DECLARE(CUSTOMOP_NHWC, "CustomOpNhwc");
REGISTER_OPTYPE_DECLARE(CUSTOMOP_NC1HWC0, "CustomOpNc1hwc0");

// Depthwise 4d_2_6d,6d_2_4d
REGISTER_OPTYPE_DECLARE(DEPTHWISEWEIGHT4D26D, "depthwise_weight_4d_2_6d");
REGISTER_OPTYPE_DECLARE(DEPTHWISEWEIGHT6D24D, "depthwise_weight_6d_2_4d");

REGISTER_OPTYPE_DECLARE(SQRTGRAD, "SqrtGrad");
REGISTER_OPTYPE_DECLARE(SIGMOIDGRAD, "SigmoidGrad");

// Horovod operator
REGISTER_OPTYPE_DECLARE(HVDCALLBACKALLREDUCE, "HorovodAllreduce");
REGISTER_OPTYPE_DECLARE(HVDCALLBACKALLGATHER, "HorovodAllgather");
REGISTER_OPTYPE_DECLARE(HVDCALLBACKBROADCAST, "HorovodBroadcast");
REGISTER_OPTYPE_DECLARE(HVDWAIT, "HorovodWait");

enum InputMode { INPUT = 0, CONST };

// Definition of the processing status enum of the process module
enum ModelProcessState {
  INIT_STATE = 0,    // init status
  WAIT_EVENT_STATE,  // Wait for the event status
  IND_RSLT_STATE,    // The model execution result is being output to the high level
  STOPPED_STATE,     // Model execution completed. The model enters this state after Model Manager::Stop
  RESERVED_STATE,    // reserved
};

// Indicates the enun definition of the execution mode of the access module
enum SysMode {
  INFERENCE = 0,  // Normal, that is, Inference mode
  DEBUG,          // Debug mode
  TIME,           // Model execution time mode, including the execution time of each OP
  STOP,           // STOP mode
  RESET,          // RESET mode
  PERFORMANCE,  // Impact of enabling the performance model: 1. The input data of the model is considered ready and does
                // not need to be converted
  ANDROID_DEBUG,  // Exports Android platform computing data
  RESERVED,       // reserved
};

// @brief encryption type of the model file
enum ModelEncryptType {
  UNENCRYPTED,  // not encrypted
  ENCRYPTED     // encrypted
};

///
/// @brief signature verification
///
enum ModelCheckType {
  CHECK,   // signature verification
  UNCHECK  // no verification
};

///
/// @brief dynamic input type
///
enum DynamicInputType {
  FIXED = 0,  // default mode
  DYNAMIC_BATCH = 1,
  DYNAMIC_IMAGE = 2,
  DYNAMIC_DIMS = 3
};

///
/// @brief magic number of the model file
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_FILE_MAGIC_NUM;

///
/// @brief model header length
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_FILE_HEAD_LEN;

///
/// @brief model name length
///
static constexpr uint32_t MODEL_NAME_LENGTH = 32;

///
/// @brief length of user-defined information
///
static constexpr uint32_t USER_DEFINE_INFO_LENGTH = 32;

///
/// @brief length of the model file signature
///
static constexpr uint32_t MODEL_FILE_CHECKSUM_LENGTH = 64;

///
/// @brief length of the reserved field in the model file header
///
static constexpr uint32_t MODEL_FILE_RESERVED_LENGTH = 79;

///
/// @ingroup domi_omg
/// @brief INPUT node type
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string INPUT_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMMY_DATA;

///
/// @ingroup domi_omg
/// @brief AIPP flag, indicating the aipp conv operator
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_CONV_FLAG;

///
/// @ingroup domi_omg
/// @brief AIPP flag, indicating the aipp data operator
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_DATA_FLAG;

// flag of the Data operator, indicating that the input will be input to the dynamic AIPP operator
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string INPUT_TO_DYNAMIC_AIPP;

// records the W dimension of the model input corresponding to the dynamic AIPP
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_RELATED_DATA_DIM_W;

// H dimension of the model input corresponding to the dynamic AIPP
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_RELATED_DATA_DIM_H;

// DATA node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DATA_TYPE;

// DATA Operator Type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_DATA_TYPE;

// framework Operator Type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string FRAMEWORK_OP_TYPE;

// DATA node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_DATA_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_NETOUTPUT_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_DEPTHCONV_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_CONV_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_FC_TYPE;
// convolution node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_NET_OUTPUT;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_END_GRAPH;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_OP_DEBUG;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_TYPE_OP_DEBUG;

// convolution node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_TYPE_CONVOLUTION;
// adds a convolutional node name for the hard AIPP
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_CONV_OP_NAME;
// delimiter of operator configuration items
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_CONF_DELIMITER;

// op attr name
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_VALUE1;

// op attr name, used to 6d_2_4d C channel
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_INPUT_CVALUE;

// op attr name
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_VALUE1;

// alpha default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float ALPHA_DEFAULT_VALUE;

// beta default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float BETA_DEFAULT_VALUE;

// coef default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float COEF_DEFAULT_VALUE;

// coef value of Relu6
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float RELU6_COEF;

// stride default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STRIDE_DEFAULT_VALUE;

// pad default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_DEFAULT_VALUE;

// dilation default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int DILATION_DEFAULT_VALUE;

// kernel default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KERNEL_DEFAULT_VALUE;

// default conv Group Size
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DEFAULT_CONV_GROUP;

// default deconv adj
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DEFAULT_DECONV_ADJ;

// indicate num 1
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NUM_ONE;

// dim default size value
static const int32_t DIM_DEFAULT_SIZE = 4;

// the shape of c must be the mutiply of 16 for depthwise
static const uint32_t DEPTHWISE_DIM_C_BASE_NUM = 16;

// C1HWNCoC0 dim size
static const int32_t DIM_C1HWNCoC0_SIZE = 6;
// C1HWNCoC0 C0 value
static const int C1HWCOC_C0_VALUE = 16;
// spatial default dim size
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t SPATIAL_DIM_DEFAULT_SIZE;

// dim extension default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t DIM_DEFAULT_VALUE;

// the first item in the weight list of opdef is filter
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t WEIGHT_FILTER_INDEX;

// the second item in the weight list of opdef is bias.
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t WEIGHT_BIAS_INDEX;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t TENSOR_ND_SUPPORT_SIZE;

// default NCHW index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_N;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_W;

// default C1HWNCoC0 index
static const uint32_t C1HWNCoC0_DIM_C1 = 0;
static const uint32_t C1HWNCoC0_DIM_H = 1;
static const uint32_t C1HWNCoC0_DIM_W = 2;
static const uint32_t C1HWNCoC0_DIM_N = 3;
static const uint32_t C1HWNCoC0_DIM_Co = 4;
static const uint32_t C1HWNCoC0_DIM_C0 = 5;

// default KCHW index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_K;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_W;

// default HWCK index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_W;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_K;

// default NHWC index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_N;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_W;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_C;

// default CHWN index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_N;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_W;

// default CHW index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHW_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHW_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHW_DIM_W;

// default HWC index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWC_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWC_DIM_W;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWC_DIM_C;
// default Pad index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_H_HEAD;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_H_TAIL;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_W_HEAD;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_W_TAIL;

// default window index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t WINDOW_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t WINDOW_W;

// default stride index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STRIDE_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STRIDE_W;

// default dilation index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DILATION_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DILATION_W;

// the num of XRBG channel
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t XRGB_CHN_NUM;

// default tensor format
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int DEFAULT_FORMAT;

// default global pooling
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const bool DEFAULT_GLOBAL_POOLING;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_VERSION;  // model version 1.0

// Number of inputs of the Eltwise operator
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int ELTWISE_MIN_INPUT_SIZE;

// flowctrl
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_STREAM_SWITCH;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_STREAM_ACTIVE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_PER_ITER;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_COND;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_INCREMENT;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_RESETVALUE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_ASSIGNADD;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_ASSIGN;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_ATOMIC_ADDR_CLEAN;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t TRUE_STREAM_ID;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STREAM_SWITCH_INPUT_NUM;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_GLOBAL_STEP;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_GLOBAL_STEP_ASSIGNADD;

static const int PLATFORM_VERSION_LEN = 20;

// Definition of the file header of the model file
struct ModelFileHeader {
  uint32_t magic = MODEL_FILE_MAGIC_NUM;               // magic number of DOMI
  uint32_t headsize = MODEL_FILE_HEAD_LEN;             // length of the model header. The value is fixed at 256
  uint32_t version = MODEL_VERSION;                    // version 1.0
  uint8_t checksum[MODEL_FILE_CHECKSUM_LENGTH] = {0};  // signature
  uint32_t length = 0;  // Ciphertext length. In the non-encryption model, the length is the plaintext length.
  uint8_t is_encrypt = ModelEncryptType::UNENCRYPTED;     // whether encrypted 0:not encrypt, 1:encrypt
  uint8_t is_checksum = ModelCheckType::CHECK;            // whether to check the checksum
  uint8_t modeltype = 0;                                  // 0：IR model 1：standard model 2: OM Tiny model
  uint8_t genmode = 0;                                    // 0：offline generate 1：online generate
  uint8_t name[MODEL_NAME_LENGTH] = {0};                  // Model name, which contains 32 characters
  uint32_t ops = 0;                                       // Computing power (Kops)
  uint8_t userdefineinfo[USER_DEFINE_INFO_LENGTH] = {0};  // User-defined information. The value contains 32 characters
  uint32_t om_ir_version = 0;
  uint8_t platform_version[PLATFORM_VERSION_LEN] = {0};
  uint8_t platform_type = {0};
  uint8_t reserved[MODEL_FILE_RESERVED_LENGTH] = {0};  // Reserved field 79
};

static constexpr uint8_t TARGET_TYPE_LTTE_8BIT = 0;
static constexpr uint8_t TARGET_TYPE_MINI_8BIT = 1;
static constexpr uint8_t TARGET_TYPE_TINY_8BIT = 2;

static constexpr int32_t PARTITION_TYPE_MODEL_DEF = 0;
static constexpr int32_t PARTITION_TYPE_WEIGHTS = 1;
static constexpr int32_t PARTITION_TYPE_TASK_INFO = 2;

// number of partitions in the current model
static constexpr uint32_t PARTITION_SIZE = 5;

enum ModelPartitionType { MODEL_DEF = 0, WEIGHTS_DATA, TASK_INFO, TBE_KERNELS, CUST_AICPU_KERNELS };

struct ModelPartitionMemInfo {
  ModelPartitionType type;
  uint32_t mem_offset;
  uint32_t mem_size;
};

struct ModelPartitionTable {
  uint32_t num;
  ModelPartitionMemInfo partition[0];
};

#define SIZE_OF_MODEL_PARTITION_TABLE(table) (sizeof(ModelPartitionTable) + sizeof(ModelPartitionMemInfo) * (table).num)

static constexpr int32_t PTHREAD_CREAT_SUCCESS = 0;  // pthread_creat success

// Filter format
typedef enum tagDomiFilterFormat {
  DOMI_FILTER_KCHW,  // KCHW
  DOMI_FILTER_HWCK,  // HWCK
  DOMI_FILTER_RESERVED
} domiFilterFormat_t;

// Const data trans type
typedef enum tagDomiConstDataTransType {
  DOMI_CONST_DATA_NOT_CHANGE = 0,  // No action is required
  DOMI_CONST_DATA_TRANS_MATMUL,    // The const input to MatMul and needs to be transposed
  DOMI_CONST_DATA_RESERVED
} domiConstDataTransType_t;

// mode of activation
typedef enum tagDomiActivationMode {
  DOMI_ACTIVATION_SIGMOID = 0,   // sigmoid
  DOMI_ACTIVATION_RELU,          // ReLU
  DOMI_ACTIVATION_TANH,          // tanh
  DOMI_ACTIVATION_CLIPPED_RELU,  // clipped ReLU
  DOMI_ACTIVATION_ELU,           // ELU
  DOMI_ACTIVATION_LEAKY_RELU,
  DOMI_ACTIVATION_ABS,             // Abs
  DOMI_ACTIVATION_RELU1,           // relu1
  DOMI_ACTIVATION_SOFTSIGN,        // softsign
  DOMI_ACTIVATION_SOFTPLUS,        // softplus
  DOMI_ACTIVATION_HARDSIGMOID,     // hardsigmoid
  DOMI_ACTIVATION_THRESHOLD_RELU,  // threshold
  DOMI_ACTIVATION_SELU,            // selu
  DOMI_ACTIVATION_LINEAR,          // linear
  DOMI_ACTIVATION_RESERVED
} domiActivationMode_t;

// mode of batchnorm
typedef enum tagDomiBatchNormMode {
  DOMI_BATCHNORM_PER_ACTIVATION = 0,  // bnScale, bnBias tensor dims are 1xCxHxW
  DOMI_BATCHNORM_SPATIAL,             // bnScale, bnBias tensor dims are 1xCx1x1
  DOMI_BATCHNORM_RESERVED
} domiBatchNormMode_t;

// eltwise mode
typedef enum tagDomiEltwiseMode {
  DOMI_ELTWISE_PROD = 0,  // prod
  DOMI_ELTWISE_SUM,       // sum
  DOMI_ELTWISE_MAX,       // max
  DOMI_ELTWISE_RESERVED
} domiEltwiseMode_t;

// mode of padding
typedef enum tagDomiPaddingMode {
  DOMI_PADDING_CEIL = 0,      // Default padding mode
  DOMI_PADDING_DIRECTASSIGN,  // Default padding mode: NOTSET
  DOMI_PADDING_VALID,         // VALID padding mode
  DOMI_PADDING_SAME,          // Padding values of 0 are always used
  DOMI_PADDING_CEIL_NEW,      // Padding values of 0 are always used
  DOMI_PADDING_VALID_NEW,     // Padding values of 0 are always used
  DOMI_PADDING_SAME_NEW,      // Padding values of 0 are always used
  DOMI_PADDING_RESERVED
} domiPaddingMode_t;

// algorithm of convolution forward
typedef enum tagDomiConvolutionFwdAlgo {
  DOMI_CONVOLUTION_FWD_ALGO_GEMM = 0,           // matrix gemm algo
  DOMI_CONVOLUTION_FWD_ALGO_WINOGRAD,           // Winograd Transform algo
  DOMI_CONVOLUTION_FWD_ALGO_GEMM_ACCU_FLOAT32,  // accumulate in L0c with FP32
  DOMI_CONVOLUTION_FWD_ALGO_RESERVED
} domiConvolutionFwdAlgo_t;

typedef enum tagDomiFullConnectFwdAlgo {
  DOMI_FULLCONNECT_FWD_ALGO_HALF = 0,  // accumulate in L0c with FP16
  DOMI_FULLCONNECT_FWD_ALGO_FLOAT32    // accumulate in L0c with FP32
} domiFullConnectFwdAlgo_t;

typedef enum tagDomiPooingFwdAlgo {
  DOMI_POOLING_FWD_ALGO_HALF = 0,  // accumulate in L0c with FP16
  DOMI_POOLING_FWD_ALGO_FLOAT32    // accumulate in L0c with FP32
} domiPooingFwdAlgo_t;

// mode of convolution
typedef enum tagDomiConvolutionMode {
  DOMI_CONV_CONVOLUTION = 0,    // math convolution
  DOMI_CONV_CROSS_CORRELATION,  // cross-correlation convolution
  DOMI_CONV_DECONVOLUTION,      // deconvolution, also named transposed convolution
  DOMI_CONV_MODE_DEPTHWISE,     // depthwise convolution
  DOMI_CONV_MODE_RESERVED
} domiConvolutionMode_t;

// softmax mode
typedef enum tagDomiSoftmaxMode {
  DOMI_SOFTMAX_MODE_INSTANCE = 0,  // compute the softmax over all C, H, W for each N
  DOMI_SOFTMAX_MODE_CHANNEL,       // compute the softmax over all C for each H, W, N
  DOMI_SOFTMAX_MODE_HEIGHT,        // compute the softmax over all H for each N, C, W
  DOMI_SOFTMAX_MODE_WIDTH,         // compute the softmax over all W for each N, C, H
  DOMI_SOFTMAX_MODE_RESERVED
} domiSoftmaxMode_t;

// softmax algorithm
typedef enum tagDomiSoftmaxAlgo {
  DOMI_SOFTMAX_FAST = 0,  // straightforward implementation
  DOMI_SOFTMAX_ACCURATE,  // subtract max from every point to avoid overflow
  DOMI_SOFTMAX_LOG,       // perform the Log softmax operation to avoid overflow
  DOMI_SOFTMAX_ACCURATE_FP32,
  DOMI_SOFTMAX_RESERVED
} domiSoftmaxAlgo_t;

// algorithm of convolution backward
typedef enum tagDomiConvolutionBwdAlgo {
  DOMI_CONVOLUTION_BWD_ALGO_GEMM = 0,  // matrix gemm algo
  DOMI_CONVOLUTION_BWD_ALGO_WINOGRAD,  // Winograd Transform algo
  DOMI_CONVOLUTION_BWD_ALGO_RESERVED
} domiConvolutionBwdAlgo_t;

// mode of pooling
typedef enum tagDomiPoolingMode {
  DOMI_POOLING_MAX = 0,  // max pooling
  DOMI_POOLING_AVG,      // average pooling
  DOMI_POOLING_L2,       // L2 pooling
  DOMI_POOLING_RESERVED
} domiPoolingMode_t;

// propagate Nan
typedef enum tagDomiNanPropagation {
  DOMI_NAN_NOT_PROPAGATE = 0,  // Nan numbers are not propagated
  DOMI_NAN_PROPAGATE,          // Nan numbers are propagated
  DOMI_NAN_PROPAGATE_RESERVED
} domiNanPropagation_t;

// mode of cropandresize
typedef enum tagDomiCropAndResizeMode {
  DOMI_RESIZE_METHOD_BILINEAR = 0,  // resize bilinear
  DOMI_RESIZE_METHOD_NEAREST,       // resize nearest
  DOMI_RESIZE_RESERVED
} domiCropAndResizeMode_t;

// yolo version
typedef enum tagDomiYoloVersion { DOMI_YOLO_V2 = 1, DOMI_YOLO_V3, DOMI_YOLO_TRSERVED } domiYoloVersion_t;

typedef enum tagDomiRNNScopePassType {
  DOMI_STATIC_BIDIRECTIONAL_RNN_GENERAL_PASS = 0,
  DOMI_DYNAMIC_BIDIRECTIONAL_RNN_GENERAL_PASS,
  DOMI_DYNAMIC_BIDIRECTIONAL_RNN_BIDAF_PASS
} domiRNNScopePassType;

// RNNDataLayout
typedef enum tagDomiRNNDataLayout {
  DOMI_RNN_ND_TBX = 0,  // data[max_time,batch_size,Xt]
  DOMI_RNN_ND_BTX,      // data[batch_size,max_time,Xt]
  DOMI_RNN_5D_TX1BX,    // data[max_time,Xt,1,batch_size,Xt]
  DOMI_RNN_5D_BX1TX,    // dataa[batch_size,Xt,1,max_time,Xt]
  DOMI_RNN_4DTBX1,
  DOMI_ENN_DL_RESERVED
} domiRNNDataLayout_t;

// RNNInputMode
typedef enum tagDomiRNNInputMode { DOMI_RNN_LINEAR_INPUT = 0, DOMI_RNN_SKIP_INPUT } domiRNNInputMode_t;

// RNNDirectionMode
typedef enum tagDomiRNNDirectionMode { DOMI_RNN_UNIDIRECTIONAL = 0, DOMI_RNN_BIDIRECTIONAL } domiDirectionMode_t;

typedef enum tagDomiPoolingCeilMode { DOMI_POOLING_FLOOR = 0, DOMI_POOLING_CEIL } domiPoolingCeilMode_t;

// RNNMode
typedef enum tagDomiRNNActivationMode {
  DOMI_RNN_ACTIVATION_SIGMOID = 0,  // sigmoid
  DOMI_RNN_ACTIVATION_TANH,         // tanh
  DOMI_RNN_ACTIVATION_RELU,         // ReLU
  DOMI_RNN_ACTIVATION_RELU1,        //  ReLU1
  DOMI_RNN_ACTIVATION_RELU6,        //  ReLU6
  DOMI_RNN_ACTIVATION_RESERVED
} domiRNNActivationMode_t;

typedef enum tagDomiRNNLSTMOutMode {
  DOMI_RNN_LSTM_OUT_SEPARATE = 0,
  DOMI_RNN_LSTM_OUT_CONCAT,
  DOMI_RNN_LSTM_OUT_RESERVED
} domiRNNLSTMOutPutMode_t;
typedef enum tagDomiRNNLSTMStateOutMode {
  DOMI_RNN_LSTM_STATE_OUT_SEPARATE = 0,
  DOMI_RNN_LSTM_STATE_OUT_CONCAT_ALL,
  DOMI_RNN_LSTM_STATE_OUT_RESERVED
} domiRNNLSTMStateOutMode_t;

typedef enum tagDomiRNNMode {
  DOMI_RNN_RELU = 0,
  DOMI_RNN_TANH,
  DOMI_LSTM,
  DOMI_GRU,
  DOMI_RNN_MODE_RESERVED
} domiRNNMode_t;

typedef enum tagDomiResizeBilinearMode {
  DOMI_RESIZE_OUTPUT_DIM_BY_ZOOM_FACTOR = 0,  // Output dimension specified by zoom factor
  DOMI_RESIZE_OUTPUT_DIM_BY_SHRINK_FACTOR,    // specified by shrink factor
  DOMI_RESIZE_OUTPUT_DIM_EXPLICIT,            // specified explicitly
  DOMI_RESIZE_OUTPUT_DIM_RESERVED
} domiResizeOutputDimMode_t;

#pragma pack(1)  // single-byte alignment
// DUMP file struct
struct FileHeader {
  int32_t Version;          // version
  int32_t Output_Offset;    // output offset address
  char Reserved[24] = {0};  // 24 bytes reserved
};

struct BasicInfo {
  struct FileHeader header;  // file header
  int32_t stream_id;         // stread id
  uint64_t start_time;       // start time
  uint64_t end_time;         // end time
  uint32_t input_size;       // input memory size
  uint32_t output_size;      // output memory size
  uint32_t weight_size;      // weight Memory Size
  uint32_t workspace_size;   // workspace
  uint32_t total_size;       // total memory size
};
#pragma pack()  // Cancels single-byte alignment
}  // namespace ge

namespace domi {
/// @brief Data structure definition related to task sinking
enum BuildMode {
  GEN_TASK_WITHOUT_L2FUSION = 3,  // Carrying task data (L2 convergence function disabled)
  GEN_TASK_WITHOUT_FUSION = 4,    // Carrying task data (all convergence functions disabled)
  GEN_TASK_WITH_FUSION = 5        // Carrying task data (with UB/L1/L2 enabled for all convergence functions)
};
}  // namespace domi

#endif  // INC_FRAMEWORK_COMMON_TYPES_H_
